/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cidetec.business;

import com.cidetec.modelo.dao.mapperinterface.IUsuarioMapper;
import com.cidetec.modelo.entidad.Usuario;
import com.cidetec.utils.Constantes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Carlos
 */
@Service("usuarioSimpleBusiness")
public class UsuarioSimpleBusiness extends AbstractBusiness{

    @Autowired
    private IUsuarioMapper usuarioMapper;

    @Transactional
    public void crearUsuarioPersona(Usuario u) {
        try {
            u.setTipoUsuario("simple");
            u.setActivo(Boolean.FALSE);
            usuarioMapper.createUsuarioSimple(u);
            setCodigo(Constantes.CODIGO_BIEN);
        } catch (DataAccessException ex) {
            ex.printStackTrace();
            setCodigo(Constantes.CODIGO_ERROR);
        }
    }
}
